
#include "Logging.h"
#include "Mutex.h"
#include "TcpClient.h"
#include "EventLoop.h"
#include "TcpConnection.h"
#include "CountDownLatch.h"
#include "EventLoopThread.h"
#include "../third/muduo/proto/dispatcher.h"
#include "../mqClient/worker.hpp"

#include "TcpServer.h"
#include "Buffer.h"
// 协议处理和分发
#include "../third/muduo/proto/dispatcher.h"
#include "../third/muduo/proto/codec.h"

using namespace std;
using namespace muduo::net;

void onConnection(const muduo::net::TcpConnectionPtr &conn)
{
    if (conn->connected())
    {
        // 创建连接
        cout << "新连接建立成功" << endl;
    }
    else
    {
        // 关闭连接
        cout << "连接关闭" << endl;
    }
}
int main()
{
    EventLoop _loop;
    TcpServer server(&_loop, muduo::net::InetAddress("0.0.0.0", 8081), "server", muduo::net::TcpServer::kReusePort);
    server.setConnectionCallback(std::bind(onConnection, placeholders::_1));
    server.start();
    _loop.loop();
    while (1)
        this_thread::sleep_for(chrono::seconds(3));
}
